package com.pucheng.bracelet.app.network

import com.afollestad.materialdialogs.utils.MDUtil
import com.blankj.utilcode.util.EncryptUtils
import com.pucheng.bracelet.app.util.CacheUtil
import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException
import kotlin.concurrent.timer

/**
 * 自定义头部参数拦截器，传入heads
 */
class MyHeadInterceptor : Interceptor {

    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        val tiemStamp = System.currentTimeMillis().toString()
        val builder = chain.request().newBuilder()
        builder.addHeader("Lang", "zh").build()
        builder.addHeader("X-Token", EncryptUtils.encryptMD5ToString("9af2f85e8865783e0e867bfb28c74860$tiemStamp")).build()
        builder.addHeader("Timestamp", tiemStamp).build()
        builder.addHeader("Platform", "android").build()
        return chain.proceed(builder.build())
    }

}